$(document).ready(function(){
	$(".itemRows").each(function(idx, item){
		$(item).mouseenter(function(event){
			$(item).css("background-color", "#fdeada");
		}).mouseleave(function(event){
			$(item).css("background-color", "#fff");
		});
	});
	
	$(":input[name='detailBtn']").each(function(idx, item){
		$(item).on("click", function(event){
			var fields = $(item).parent("td").parent("tr").find(">td");
			var cdTpId = $(fields).eq(1).text();
			var cdTpAlias = $(fields).eq(2).text();
			var options = new Object();
			options["url"] = "/template/system/codeType/_detail/"+cdTpId;
			options["jqwId"] = "detailJqwPop";
			options["title"] = "["+cdTpAlias+"] 상세 정보";
			options["resizable"] = false;
			options["width"] = "500";
			options["height"] = "228";
			jqwOpen(options);
		});
	});
	
	$(":input[name='reviseBtn']").each(function(idx, item){
		$(item).on("click", function(event){
			var fields = $(item).parent("td").parent("tr").find(">td");
			var cdTpId = $(fields).eq(1).text();
			var cdTpAlias = $(fields).eq(2).text();
			var options = new Object();
			options["url"] = "/template/system/codeType/_regFormRevise/"+cdTpId;
			options["jqwId"] = "reviseJqwPop";
			options["title"] = "["+cdTpAlias+"] 코드 유형 수정";
			options["resizable"] = false;
			options["width"] = "500";
			options["height"] = "230";
			jqwOpen(options);
		});
	});
	
	$(":input[name='delBtn']").each(function(idx, item){
		$(item).on("click", function(event){
			var fields = $(item).parent("td").parent("tr").find(">td");
			var cdTpId = $(fields).eq(1).text();
			var cdTpAlias = $(fields).eq(2).text();
			
			if(confirm("["+cdTpAlias+"] 을 삭제 하시겠습니까?")){
				var url = "/template/system/codeType/_deleteCodeType";
				var options = new Object();
				options["url"] = url;
				options["data"] = "cdTpId="+cdTpId;//"frm:frmCdTpReg"
				jqwSave(options);
			}
		});
	});	
});

function jqwSave(opts){
	var obj = $(".pageNavi").find(".numberingOn");
	naviNumClickEventReg(obj);
	
	var data = opts["data"];
	var options = new Object();
	options["url"] = opts["url"];
	options["type"] = "POST";
	options["dataType"] = "json";
	options["data"] = data;
	options["triggerObj"] = obj;	//트리 메뉴에서 현재 화면을 triggering(to click) 할 수 있는 오브젝트.
	options["jqwType"] = "save";	//< "popup" | "save" | [null | ""] >
	options["jqwClose"] = true;
	
	var jqw = new jqWindow();
	jqw.jqwSet(options);
	jqw.loadJqWindow();
}
